#!/usr/bin/env python3
# -*- coding: utf-8 -*-

transform_file = '/Users/David/Desktop/BPNN数据/test_data_1000_label.csv'
transform_target = '/Users/David/Desktop/BPNN数据/test_data_1000_label_numeric.csv'
transform_result = []

with open(transform_file, 'r', encoding='utf-8') as f:
    for line in f.readlines():
        level_array = []
        for level in line.strip('\n').split(','):
            if level == '不及格':
                level = 0.3
            if level == '及格':
                level = 0.6
            if level == '良好':
                level = 0.8
            if level == '优秀':
                level = 1.0
            level_array.append(level)
        transform_result.append(level_array)

with open(transform_target, 'w', encoding='utf-8') as f:
    for line in transform_result:
        line = map(str, line)
        f.write(','.join(line) + '\n')
